package com.mybills.proj;


import com.mybills.proj.pf.googlecal;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;

public class details_list extends Activity {
	static String bill_id = ""; 
	static String bill_place = "";
	static String bill_amount = "";
	static String start_time = "";
	static String end_time = "";
	static String date = "";
	String mdate1;
	String mdate2;
	String mdate3;
	public String getDate() {
		return date;
	}

	public static void setDate(String date) {
		details_list.date = date;
	}
	private TextView mDateDisplay;
	
    private Button mPickDate;
    private int mYear = 2000;
    private int mMonth=3;
    private int mDay=5;
    static final int DATE_DIALOG_ID = 0;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_details);
       // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
       // StrictMode.setThreadPolicy(policy);
        
        mPickDate = (Button) findViewById(R.id.pickDate);
        mPickDate.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                showDialog(DATE_DIALOG_ID);
            }
        });
        
        pf p = new pf();
        pf.googlecal add = p.new googlecal();
         mDateDisplay = (TextView) findViewById(R.id.resultText);
        TextView tv1 = (TextView) findViewById(R.id.resultText1);
        TextView tv2 = (TextView) findViewById(R.id.resultText2);
        TextView tv3 = (TextView) findViewById(R.id.resultText3);
        TextView tv4 = (TextView) findViewById(R.id.resultText4);
        TextView tv5 = (TextView) findViewById(R.id.resultText5);
        Bundle bundle=getIntent().getExtras();
        setBill_id(bundle.getString("BILL_ID"));
        setBill_place(bundle.getString("BILL_PLACE"));
        setBill_amount(bundle.getString("BILL_AMOUNT"));
        setStart_time(bundle.getString("STARTTIME"));
        setEnd_time(bundle.getString("ENDTIME"));
        tv1.setText(getBill_id().toString());
        tv2.setText(getBill_place().toString());
        tv3.setText(getBill_amount().toString());
        tv4.setText(getStart_time().toString());
        tv5.setText(getEnd_time().toString());
        MyBllsActivity mba = new MyBllsActivity();
        details_list dl = new details_list();
    	mba.setEmail( bundle.getString("emaiL"));
        mba.setPwd(bundle.getString("pWd"));
    	System.out.println("---------"+mba.getEmail()+"details.list");
    	System.out.println(dl.getDate()+"------"+dl.getStart_time());
        System.out.println("-------------------------u rock-----------------------------------");
        
		
		
		/*try {
			add.createEvent(mba,dl);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println(e+"not-added");
		
		}*/
		
	}
	
       public static String getStart_time() {
		return start_time;
	}
	public static void setStart_time(String startTime) {
		start_time = startTime;
	}
	public static String getEnd_time() {
		return end_time;
	}
	public static void setEnd_time(String endTime) {
		end_time = endTime;
	}
	
	public String getBill_id() {
		return bill_id;
	}
	public void setBill_id(String billId) {
		bill_id = billId;
	}
	public String getBill_place() {
		return bill_place;
	}
	public void setBill_place(String billPlace) {
		bill_place = billPlace;
	}
	public String getBill_amount() {
		return bill_amount;
	}
	public void setBill_amount(String billAmount) {
		bill_amount = billAmount;
	}
	
	private void updateDisplay() {
        mDateDisplay.setText(
            new StringBuilder()
                    // Month is 0 based so add 1
                    .append(mYear).append("-")
                    .append(mMonth + 1).append("-")
                    .append(mDay).append(""));
        mdate1 = Integer.toString(mMonth+1);
        mdate2 = Integer.toString(mDay);
        mdate3 = Integer.toString(mYear);
        setDate(mdate3+"-"+mdate1+"-"+mdate2);
    }
	private DatePickerDialog.OnDateSetListener mDateSetListener =
        new DatePickerDialog.OnDateSetListener() {

            public void onDateSet(DatePicker view, int year, 
                                  int monthOfYear, int dayOfMonth) {
                mYear = year;
                mMonth = monthOfYear;
                mDay = dayOfMonth;
                updateDisplay();
            }
        };
        @Override
        protected Dialog onCreateDialog(int id) {
            switch (id) {
            case DATE_DIALOG_ID:
                return new DatePickerDialog(this,
                            mDateSetListener,
                            mYear, mMonth, mDay);
            }
            return null;
        }
        public void create_event(View v){
        	Intent it = new Intent();
        	Bundle bundle=getIntent().getExtras();
        	it.putExtra("_email", bundle.getString("emaiL"));
    		it.putExtra("_pwd", bundle.getString("pWd"));
        	it.putExtra("date", getDate());
        	it.putExtra("starttime", getStart_time().toString() );
        	it.putExtra("endtime", getEnd_time().toString() );
        	it.putExtra("Billid",getBill_id().toString() );
        	it.putExtra("BILL_Place",getBill_place().toString() );
        	it.putExtra("BILL_Amount",getBill_amount().toString() );
        	it.setClass(this, event.class);
        	startActivity(it);
        }
        
}
